/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.panel;

import java.util.ArrayList;
import model.Room;

/**
 *
 * @author user
 */
public class RoomCategory {

    public int id;
    public String name;
    public ArrayList<RoomCategory> subCategories;
    public ArrayList<Room> rooms;

    public RoomCategory(int id, String name) {
        this.id = id;
        this.name = name;
        subCategories = new ArrayList<RoomCategory>();
        rooms = new ArrayList<Room>();
    }

    public RoomCategory find(int id) {
        if (id == this.id) {
            return this;
        }

        for (int i = 0; i < subCategories.size(); ++i) {
            RoomCategory rm = subCategories.get(i);
            RoomCategory find = rm.find(id);
            if (find != null) {
                return find;
            }
        }

        return null;
    }

    public RoomCategory find(String name) {
        if (this.name.equals(name)) {
            return this;
        }

        for (int i = 0; i < subCategories.size(); ++i) {
            RoomCategory rm = subCategories.get(i);
            RoomCategory find = rm.find(name);
            if (find != null) {
                return find;
            }
        }

        return null;
    }
}
